home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / cgraphix / kerror.c < prev    next >
Text File  |  1986-05-07  |  2KB  |  108 lines

  1. /* «RM120»«PL99999»«TS4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76» */
  2. #include    <stdio.h>
  3. #define    EXTERN    extern
  4. #include    <typedef.h>
  5.  
  6. #define    CTRL_C    '\003'
  7. #define CTRL_M    '\015'
  8.  
  9. void SetMessageOn()
  10. {
  11.     MessageGlb = TRUE;
  12. }
  13.  
  14.  
  15. void SetMessageOff()
  16. {
  17.     MessageGlb = FALSE;
  18. }
  19.  
  20.  
  21. void SetBreakOff()
  22. {
  23.     BrkGlb = FALSE;
  24. }
  25.  
  26.  
  27. void SetBreakOn()
  28. {
  29.     BrkGlb = TRUE;
  30. }
  31.  
  32.  
  33. static char *HexString(byt)
  34. int        byt;
  35. {
  36.     static char hex[] = "0123456789ABCDEF";
  37.     static char dest[3] = "  \0";
  38.  
  39.     dest[0] = hex[byt >> 4];
  40.     dest[1] = hex[byt & 0x0f];
  41.     return(dest);
  42. }
  43.  
  44.  
  45. void error(ErrProc, ErrCode)
  46. int        ErrProc, ErrCode;
  47. {
  48.     int        NLevels, PCValue, XLoc, YLoc;
  49.     char    Ch;
  50.  
  51.     if (!((ErrProc >= 0) && (ErrProc <= MaxProcsGlb))) {
  52.         LeaveGraphic();
  53.         fprintf(stderr, "FATAL ERROR 1: illegal procedure number %d.\n",
  54.             ErrProc);
  55.         exit(1);
  56.     }
  57.     if (!((ErrCode >= 0) && (ErrCode <= MaxErrsGlb))) {
  58.         LeaveGraphic();
  59.         fprintf(stderr, "FATAL ERROR 2: illegal error code %d.\n", ErrCode);
  60.         exit(1);
  61.     }
  62.  
  63.     ErrCodeGlb = ErrCode;
  64.  
  65.     if (BrkGlb)
  66.         LeaveGraphic();
  67.  
  68.     if (MessageGlb || BrkGlb) {
  69.         XLoc = XTextGlb;
  70.         YLoc = YTextGlb;
  71.         GotoXY(1,24);
  72.         ClrEOL();
  73.         fprintf(stderr, "Graphix error #%d in procedure #%d",
  74.             ErrCode, ErrProc);
  75.         if (MessageGlb) {
  76.             ClrEOL;
  77.             fprintf(stderr, "(%s in %s)\n",
  78.                 ErrorCode[ErrCode], ErrorProc[ErrProc]);
  79.         }
  80.     }
  81.     if (BrkGlb && !MessageGlb)
  82.         exit(1);
  83.  
  84.     if (MessageGlb) {
  85.         fprintf(stderr, ".  Hit enter: ");
  86.         do {
  87.             Ch = inkey();
  88.         } while ((Ch != CTRL_M) && (Ch != CTRL_C));
  89.         if (Ch == CTRL_C) {
  90.             LeaveGraphic();
  91.             exit(1);
  92.         }
  93.         GotoXY(XLoc,YLoc);
  94.     }
  95. }
  96.  
  97.  
  98.  
  99. int GetErrorCode()
  100. {
  101.     int retc;
  102.  
  103.     retc = ErrCodeGlb;
  104.     ErrCodeGlb = 0;
  105.     return(retc);
  106. }
  107.  
  108.